<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      :row-style="rowStyle"
      :header-cell-style="getRowClass">
      <el-table-column
        type="selection">
      </el-table-column>
      <el-table-column
        type="index"
        :index="indexMethod">
      </el-table-column>
      <el-table-column
        prop="no"
        label="学号"
        align="center"
        sortable>
      </el-table-column>
      <el-table-column
        prop="date"
        label="日期"
        align="center">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        align="center">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址"
        align="center">
      </el-table-column>
      <el-table-column
        label="操作"
        align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            @click="handleView(scope.$index, scope.row)">查看</el-button>
          <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  name: 'Guide11',
  data () {
    return {
      table_color: this.$GlobalConst.GlobalColor.table_color,
      tableData: [{
        no: 18031211487,
        date: '2016-05-07',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        no: 18031211488,
        date: '2016-05-07',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        no: 18031211489,
        date: '2016-05-07',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        no: 18031211490,
        date: '2016-05-07',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }]
    }
  },
  methods: {
    handleView (index, row) {
      console.log(index, row)
      this.$router.push({
        path: '/home/detail',
        query: {
          no: row.no
        }
      })
    },
    handleEdit (index, row) {
      console.log(index, row)
    },
    handleDelete (index, row) {
      console.log(index, row)
    },
    indexMethod (index) {
      return index + 1
    },
    getRowClass ({ rowIndex }) {
      return {
        color: this.table_color.table_title_text_color,
        background: this.table_color.table_title_background_color
      }
    },
    rowStyle ({ row, rowIndex }) {
      if ((rowIndex + 1) % 2 === 0) {
        return {
          color: this.table_color.table_row_text_color,
          background: this.table_color.table_row_background_color
        }
      } else {
        return {
          color: this.table_color.table_row2_text_color,
          background: this.table_color.table_row2_background_color
        }
      }
    }
  },
  mounted () {

  }
}
</script>

<style lang="scss" scoped>

</style>
